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 foo = { | |
bar: function() { return this.baz; }, | |
baz: 1 | |
}; | |
(function() { | |
return typeof arguments[0](); | |
})(foo.bar); | |
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 x = 1; | |
if (function f() {}) { | |
x += typeof f; | |
} | |
x; | |
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(foo) { | |
return typeof foo.bar; | |
})({ foo: { bar: 1 } }); |
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 f() { | |
function f() { return 1; } | |
return f(); | |
function f() { return 2; } | |
})(); |
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 f() { | |
return f; | |
} | |
new f() instanceof f; |
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
// 方法一:split | |
function strHump(str) { | |
if (typeof str !== 'string') { | |
return str; | |
} | |
var arr = str.split('-'); | |
for (var i= 1,len=arr.length; i<len; i++) { | |
arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].substring(1); |
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
// 方法一:string | |
function multiChar(str) { | |
if (typeof str !== 'string') { | |
return ''; | |
} | |
var obj = {}, | |
num = 0, | |
value = '', | |
ch = ''; |
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 a = function() { console.log('1'); }; | |
function a() { | |
console.log('2'); | |
} | |
a(); |
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
// 方法一:string | |
function thousandSymbol(str) { | |
if (typeof str !== 'string') { | |
return str; | |
} | |
var iNum = str.length % 3, | |
prev = '', | |
arr = []; |
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
/* a,b两个变量,不用第三个变量来交换两个变量的值 */ | |
// a,b为数字 | |
var a = 1, | |
b = 2; | |
a = a + b; | |
b = a - b; | |
a = a - b; | |
OlderNewer