以下理解未必完全正确,但包含了若干方面的可能因素,可日后进一步探究(QQs:不太会探究):jenkins 在打包angular过程中为webpack的sass-loader安装所需包node-sass,但是缺少node-gyp,python等工具链的调用权限,因而build失败,至于npm install为什么会build,electron编译过程中也遇到过,编译对象是package中调用的c++库。对此的解决方案之一是在jenkins所在的物理机上全局安装node-sass,当下的默认版本是5.0.0,曾尝试在项目package.json中将node-sass更新为5.0.0,然而angular9中的sass-loader似乎是支持node-sass^4.0.0,因此出现“Node Sass version 5.0.0 is incompatible with ^4.0.0”的报错,应在全局重装npm i -g node-sass@4
function SuperType(){ this.colors = ["red", "blue", "green"]; } function SubType(){ //继承了 SuperType SuperType.call(this); } var instance1 = new SubType(); instance1.colors.push("black"); alert(instance1.colors);//"red,blue,green,black" var instance2 = new SubType(); alert(instance2.colors);//"red,blue,green"
传参
1 2 3 4 5 6 7 8 9 10
function SuperType(name){ this.name = name; } function SubType(){ SuperType.call(this, "Nicholas");//调用SuperType构造方法 this.age = 29; //实例属性 } var instance = new SubType(); alert(instance.name); //"Nicholas"; alert(instance.age);//29
var instance1 = new SubType(); instance1.colors.push("black"); alert(instance1.colors);//"red,blue,green,black" var instance2 = new SubType(); alert(instance2.colors);//"red,blue,green"
function object(o){ function F(){} F.prototype = o; return new F(); }
关于ES5 Object.create();
操作符instanceOf
1 2 3 4 5 6 7 8 9 10 11
function instance_of(L, R) {//L 表示左表达式,R 表示右表达式 var O = R.prototype;// 取 R 的显示原型 L = L.__proto__;// 取 L 的隐式原型 while (true) { if (L === null) return false; if (O === L)// 这里重点:当 O 严格等于 L 时,返回 true return true; L = L.__proto__; } }
let text = "<h1>Winter is coming</h1>"; let myRegex = /<.*>/; let result = text.match(myRegex); // matching <h1>Winter is coming</h1>
myRegex = /<.*?>/; result = text.match(myRegex); // matching <h1>
let article = "<h1>Winter is coming</h1><div></div><h1>north remembers</h1><h1>dragon is coming</h1><h1>the Queen is coming</h1>" let titles = article.match(/<h1>.*?<\/h1>/g)