JavaScript高级编程第四章(变量,作用域,内存问题)的学习摘录 纯手打
发布日期:2021-05-10 02:10:29 浏览次数:27 分类:精选文章

本文共 3903 字,大约阅读时间需要 13 分钟。

JS���������������������������������������

���������JavaScript������������������������������������������������������������������������������������������������������������������������������������������������

���������������������

1.1 ������������������������������������

JavaScript������������������������number���string���boolean���null���undefined���symbol������������������������true���false���������������������������������������������������������������������������������

������������������������������������������������������������

var a = 10;
var b = a;
a = 20;
// ������b������������10������������������������

������������������������������Pointer���������������������������������������������������������������������������������������������������������������������������

var obj = new Object();
var a = obj;
var b = a;
a.name = 'test';
// ������b.name���������'test'���������������������������

1.2 dynamic properties

���������������������������person.name���������������������������������������������������������������������������������

var person = new Object();
person.name = 'sdf'; // ������������������
var name = 'sdf';
name.age = 23; �� �� �� // ���������������������������������������������undefined

1.3 ���������������

������������������������������������

  • ���������������������������������������
  • ������������������������������������������������������������

���������

a = {age: 20};
b = a; // b���a���������������������

1.4 ������������������

������typeof���������������������������instanceof������������������������������

  • typeof���null������'object'���������������������
  • ������������instanceof������������������������:
console.log(person instanceof Object); // true
console.log([] instanceof Object); // true
console.log('/regex/. instanceof RegExp); // true

������������������

2.1 ������������������

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

2.2 ������������������

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

2.3 ������������������������������

JavaScript������������������������������������������������for loop���if statement���������������������������������������������������������������

if (true) {
var a = 1; // a���������������������������
}

2.4 with������������

with������������������������������������������������������������������

with(location) {
var url = href + '?debug=true';
}

���������url������������������������������������������

������������������

3.1 ������������������

JavaScript������������������������������������������������������������������������������������������������������������������������������������������������

  • ������������������������������
  • ������CollectGarbage���pera.collect���������������������

3.2 ��� ���������������

������������������������������������������������������������������������

a = new Object();
a.waitFor������
b = new Object();
bonta]).para���
// declar both a and b, and clear their references to avoid cycles

3.3 ������������������

  • ���������������������null������������������
  • ������������������var������������������������������������������
  • ������������������������������������������������

������������������������

  • ���������������������������
  • ������������������������������������
  • ������������������������������������������������������������������������������������

    ������������������

    • ������������������������������������������������
    • ������������������������������������������������
    • minimalista���������������������������������������
    • ���������������������������������������������������

    ���������������������������������������JavaScript������������������������������������������������������������������������������

    上一篇:JavaScript外部调用Js(自己理解加参考百度)
    下一篇:html,css,javascript注释

    发表评论

    最新留言

    不错!
    [***.144.177.141]2025年04月04日 23时56分57秒