Professional JS for Web Developers (third edition) 随手笔记(1)前4章

2 JavaScript in HTML

deferred scripts

  1. the purpose of defer is to indicate that a script won’t be changing the structure of the page as it executes.
  2. Setting the defer attribute on a

Asynchronous Scripts

  1. Also similar to defer, async applies only to external scripts and signals the browser to begin downloading the file immediately. Unlike defer, scripts marked as async are not guarantedd to execute in the order in which th
  2. ey they are specified.
  3. an async scripts is to indicate that the page need not wait for the script to be downloaded and executed before continuing to load, and it also need not wait for another script to load an execute before it can do the same. … not modify the DOM as they are loading.
    这里写图片描述

SUMMARY

  • you can defer a script’s execution until after the document has rendered by using the defer attribute.
  • .. a script need not wait for other scripts and not block the document rendering by using the async attribute. Asynchronous scripts are not guaranteed to execute in the order in which they occur in the page.

3 Language Basics

DATA TYPES

  • five simple data types(primitive types):Undefined, Null, Boolean, Number, and String。
The Null Type
  • undefined is a derivative(衍生物) of null, null == undefined //true
The Boolean Type
  • These values are distinct from numeric values, so true is not equal to 1, and false is not equal to 0.

  • 1==true, 0==false

The Object type

each object instance has the following properties and methods:
- constructor:the function that was used to create the object.
- hasOwnProperty(propertyName)
- isPrototypeOf(object)
- propertyIsEnumerable(propertyName)
- toLocaleString()
- toString()
- valueOf()

Understanding Arguments
  • …arguments in ECMAScript are represented as an array internally. … In fact, there actually is an arguments object …
  • the arguments object acts like an array(though it isn’t an instance of Array) …
function doAdd(num1,num2){
        arguments[1]=10;
        alert( arguments[0] + num2 );
}

this version of doAdd overwrites the second argument with a value of 10. Because values in the arguments object are automatically reflected by the corresponding named arguments, the change to arguments[1] also changes the value of num2, so both have a value of 10. This doesn’t mean that both access the same memory space, though; their memory spaces are separate but happen to be kept in sync. This effect goes only one way: changing the named argument doen not result in a change to the corresponding value in arugments. Another thing to keep in mind : if only one argument is passed in ,then setting arguments[1] to a value will not be reflected by the named argument. This is because the length of the arguments object is set based on the number of arguments passed in , not the number of named arguments listed for the function.

4 Variables ,Scope, and Memory

PRIMITIVE AND REFERENCE VALUES

Copying Values

When a reference value is assigned from one variable to another, the value stored on the variable object is alse copied into the location for the new variable. The difference is that this value is actually a pointer to an object stored on the heap.
这里写图片描述

Determining Type

typeof
result = variable instanceof construtor

This book provides a developer-level introduction along with more advanced and useful features of JavaScript. Coverage includes: JavaScript use with HTML to create dynamic webpages, language concepts including syntax and flow control statementsvariable handling given their loosely typed naturebuilt-in reference types such as object and arrayobject-oriented programingpowerful aspects of function expressionsBrowser Object Model allowing interaction with the browser itselfdetecting the client and its capabilitiesDocument Object Model (DOM) objects available in DOM Level 1how DOM Levels 2 and 3 augmented the DOMevents, legacy support, and how the DOM redefined how events should workenhancing form interactions and working around browser limitationsusing the tag to create on-the-fly graphicsJavaScript API changes in HTML5how browsers handle JavaScript errors and error handlingfeatures of JavaScript used to read and manipulate XML datathe JSON data format as an alternative to XMLAjax techniques including the use of XMLHttpRequest object and CORScomplex patterns including function currying, partial function application, and dynamic functionsoffline detection and storing data on the client machinetechniques for JavaScript in an enterprise environment for better maintainability This book is aimed at three groups of readers: Experienced object-oriented programming developers looking to learn JavaScript as it relates to traditional OO languages such as Java and C++; Web application developers attempting to enhance site usability; novice JavaScript developers. Nicholas C. Zakas worked with the Web for over a decade. He has worked on corporate intranet applications used by some of the largest companies in the world and large-scale consumer websites such as MyYahoo! and the Yahoo! homepage. He regularly gives talks at companies and conferences regarding front-end best practices and new technology.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值