copy node javascript code example
Example 1: js clone element
// Syntax:
let newClone = node.cloneNode([deep])
// Example:
let p = document.getElementById("para1")
let p_prime = p.cloneNode(true)
Example 2: node.js copy to clipboard
// Copy to clipboard in node.js
const child_process = require('child_process')
// This uses an external application for clipboard access, so fill it in here
// Some options: pbcopy (macOS), xclip (Linux or anywhere with Xlib)
const COPY_APP = 'xclip'
function copy(data, encoding='utf8') {
const proc = child_process.spawn(COPY_APP)
proc.stdin.write(data, {encoding})
proc.stdin.end()
}