js學習筆記 (繼續)

 

轉義字符
不斷行的空白格 nbsp:1 2
半方大的空白 ensp 1 2
全方大的空白 emsp 1 2
小於號 < &lt;
大於號 > &gt;
雙引號 " &quot;
AND符號 & &amp;
其餘請參考http://114.xixik.com/character/javascript

localCompare()比較字符串的位置 依據不一樣地方的實現java

Math對象
Math.ceil() 向上取
Math.floor() 向下取
Math.round() 四捨五入
1>Math.random()>=0dom

執行環境
var a="123";
function s(){
a="456";
}
alert(a); //a的值爲123函數

with(location){
alert(href);
}
with語句能夠延長做用域鏈,try catch中的catch塊也能夠
"use strict"模式不能使用with,with用多了會使性能受到影響
因爲javascript沒有塊級做用域,當在函數內部使用var定義變量時,變量在外邊不可見。
而不使用var定義時,變量可見。性能

js中常見的兩種垃圾收集的方式是標記清除和引用記數。
在IE中可使用window.CollectGarbage()強制垃圾回收
若是爲了手動管理內存,能夠顯式解除內存的引用對象


JSON.stringify({a:1,b:2},function f(key, value) {
console.log(value);
if (typeof value === "number") {
value = 2 * value;
}
return value;
})
上面代碼中,對象o一共會被f函數處理三次。第一次鍵名爲空,鍵值是整個對象o;第二次鍵名爲a,鍵值是{b:1};第三次鍵名爲b,鍵值爲1。ip

相關文章
相關標籤/搜索