JavaScript Learning notes (i)

Source: Internet
Author: User

= = = "2 = with 3 =" ===var result1= ("55" ==55); -Truevar result2= ("55" ===55); ->falsealert (result1+ "; "+result2");//=====for In======for (var propname in window) {document.write (propname);d ocument.write ("</br>");} The return statement of the = = function =====function sum (A, b) {return A+b;alert ("Hello"),//return statements will not be executed}document.write (sum (2,3)); function Sayhi (name,message) {return;//Output Undefinedalert ("Heloo");//The same Heloo will not output}document.write (Sayhi ("Me")); document.write ("<br/>"), function Sayhi () {document.write ("Hello" +arguments[0]+ "," +arguments[1]);} Sayhi ("He", "said"),//========arguments with parameters =====function Doadd (num1,num2) {Arguments[1]=10;alert (arguments[0]+num2 );} Doadd (11,2); 21DOADD (11); ->nan, only one parameter is passed in, and the value set by arguments[1] is not reflected in the named parameter.   Doadd (); ->nan, a named parameter that does not pass a value, is automatically assigned the undefined value. = = = function with no return statement ======/*function Add (A, B) {var result = a+b;} Alert (Add (2,3)); ->undefined, a function that does not specify a return value returns a special undefined value. *///======object======/*var person = new Object ();p erson.name = "Nicolas"; alert (pErson.name); ->nicolas;var name= "Nicolas"; name.age = 27;alert (name.age); ->undefined, you cannot add a property to a base type value. *///======== basic type and reference type ======function Addten (num) {num = 10;return num;} var count = 20;var result = Addten (count); alert (count); ->20alert (result); ->30function setName (obj) {obj.name = "Nicolas";} var person = new Object (), setName (person);d ocument.write (person.name); ->nicolasdocument.write ("<br/>"), function setName1 (obj) {obj.name = "Angle"; obj = new Object (); obj.name = " Greg ";} var person1 = new Object (); setName1 (Person1);d ocument.write (person1.name); ->angle, indicating that the JavaScript object parameter is a value pass alert (Person1 instanceof object);//========json========/* * Json.stringify () Serializes a JavaScript object into a JSON string * Any property with a value of undefined will also be skipped * */var book = {title: "Professional JavaScript", authors:[" Nicholas c. Zakas "],edition:3,year:2011,denote:undefined};var jsontext = json.stringify (book); alert (jsontext); var CopyBook = Json.parse (jsontext); Alert (copybook["year"]);/* * Filter Results * Json.striNgfy (array,["param1", "param2"]) */var JsonText1 = json.stringify (book,["title", "edition"]);d Ocument.write ( JSONTEXT1);/* * String indent *json.stringify (value [, Replacer] [, space]) *//*var jsonText2 = json.stringify (book,null,4);//Indent 4 A space alert (JSONTEXT2);/* * ToJson */var Book1 = {title: "Professional JavaScript", authors:["Nicholas c. Zakas"],edition:3, Year:2011,tojson:function () {return this;}}; var jsonText3 = json.stringify (BOOK1); alert (JSONTEXT3);

  

JavaScript Learning notes (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.