JavaScript studies four

2019-06-01

09:09:23

Insist on, come on! ! !

Learning function

<HTML> 
    <head> 
        <Script of the type = "text / JavaScript"> // create objects // Object () is a function // use function calls the new keyword, the constructor constructor // constructor is designed to function to create an object // create an object var obj = new new object (); // add a property to the object // syntax: object attribute name = attribute value 
            obj.name = "Monkey King" ; 
            obj.gender = "male" ; 
            obj.age = 18 is ; // read the properties object             the console.log (obj.name); // modify the properties of objects 
            obj.name = "pig" ;// delete the object's properties
            
            
            
            

            
            
            

            
            

            


            

            
            // syntax: delete objects. Attribute 
            Delete obj.name;
              
         </ Script> 
    </ head> 
    <body> 
    </ body> 
</ HTML>
<HTML> 

<head> 
    <Script type = "text / JavaScript"> // property name: // attribute name of the object does not comply with the mandatory requirements of the specification identifier // if you want to use a special attribute name, using the // grammar : Object [ "properties"] = attribute value var obj = new new Object (); 
        obj [ "123"] = 789 ;
         var n-= "123" ; 
        the console.log (obj [n-]); // attribute value // It may be any type of data // in operator // by the operator to check whether a specified object attribute // syntax: "properties" Object in 
        the console.log ( "123" in obj);
     </ Script> 
</ head> 
<body>
</body>
        
        
        
        
        


        
        



        
        
        


</html>
<HTML> 

<head> 
    <Script of the type = "text / JavaScript"> // function is also an object // create a function var Fun = new new Function (); // call the function // syntax: function object ()         Fun () ; // use the function to create a function declaration // syntax: // function name of the function ([parameter 1, parameter 2, ......]) // { // } function fun2 () { 
            the console.log ( "the this My Fun SECOND IS " );   
        } // function expression create functions // var function name = function ([parameter 1, parameter 2, ......]) // { // } //
        


        
        

        
        


        
        
            
            

            
        


        
        
        

        
        Assigning an anonymous function FUN3 
        var FUN3 = function () 
        { 

        }


     </ Script> 
</ head> 

<body> 
</ body> 

</ HTML>

 

< html>

< head>
< script type= "text/javascript">
// property name:
// property name of the object does not comply with the mandatory requirements of the specification identifier
// If you want to use a special attribute names, using
// syntax: Object [ "Properties"] = attribute value
var obj = new the Object ();

obj[ "123"] = 789;
var n = "123";
console. log(obj[n]);

//属性值
//可以是任意的数据类型



//in 运算符
//通过该运算符可以检查一个对象中是否有在指定的属性
//语法: “属性” in 对象
console. log( "123" in obj);
</ script>
</ head>

< body>
</ body>

</ html>

Guess you like

Origin www.cnblogs.com/Artimis-fightting/p/10958649.html