This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pcsc = require('pcsclite'); | |
var pcsc = pcsc(); | |
pcsc.on('reader', function(reader) { | |
console.log('New reader detected', reader.name); | |
reader.on('error', function(err) { | |
console.log('Error(', this.name, '):', err.message); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lengthOfLongestSubstring = function(s) { | |
var start = 0 | |
var end = 0 | |
var temp = '' | |
var result = '' | |
var times = 1 | |
while (end < s.length) { | |
console.log(`#${times}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> | |
<input type="hidden" name="cmd" value="_s-xclick"> | |
<input type="hidden" name="hosted_button_id" value="4MVG5ES3Z4Y3J"> | |
<input type="image" src="https://www.paypalobjects.com/zh_TW/TW/i/btn/btn_buynowCC_LG_wCUP.gif" border="0" name="submit" | |
alt="PayPal - 更安全、更簡單的線上付款方式!"> | |
<img alt="" border="0" src="https://www.paypalobjects.com/zh_TW/i/scr/pixel.gif" width="1" height="1"> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const regexpTable = { | |
tw: /^09\d{8}$/, | |
cn: /^1[34578]\d{9}$/, | |
hk: /^([6|9])\d{7}$/, | |
mo: /^[0][9]\d{8}$/ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In web browsers, the window object is also the global object: | |
console.log(this === window); // true | |
a = 37; | |
console.log(window.a); // 37 | |
this.b = "MDN"; | |
console.log(window.b) // "MDN" | |
console.log(b) // "MDN" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f1() { | |
return this; | |
} | |
// In a browser: | |
f1() === window; // true | |
// In Node: | |
f1() === global; // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f2(){ | |
"use strict"; // 嚴格模式 | |
return this; | |
} | |
f2() === undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An object can be passed as the first argument to call or apply and this will be bound to it. | |
var obj = {a: 'Custom'}; | |
// This property is set on the global object | |
var a = 'Global'; | |
function whatsThis(arg) { | |
return this.a; // The value of this is dependent on how the function is called | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bar() { | |
console.log(Object.prototype.toString.call(this)); | |
} | |
bar.call(7); // [object Number] | |
bar.call('foo'); // [Object String] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var globalObject = this; | |
var foo = (() => this); | |
console.log(foo() === globalObject); // true |