javascript 所有JavaScript部件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 所有JavaScript部件相关的知识,希望对你有一定的参考价值。

// <script type = "text/javascript"> </script  ---head section
// <script type="text/javascript" src="externalFile.js" ></script 

  // JS DATATYPES :
  // Numbers, Strings, Booleans, undefined, Null
  // js Variables
  
  var moneyVariable = 100.25;
  var nameVariable = "myname";
  
  // function or method
  
  function sayHello(){
    console.log("helloworld")
    //condition withlogical operators
{    if (a == b && b = a || c < d){
        // condition 
    }else if(10 > 5) {
      // condition 
    }else{
  // condition 
    }
}  }


function switchStmt(){
  switch (expression){
    case "condition" 1: doSomething;
    break
      case "condition" 2: doSomething;
    break;
    default: doSomething;
  }
}


// loops
// while loops

while (a > b){
  // run code if condition is true
}

// do while run at least once.

do{
  // code to run
var count = 0;
count++;
  
}while  (count < 1000){
  // increment count again
}

// for loops
/* for (init; test condition; iteration stmt){
  statements to execute if test is true
 }
 */
 for (count = 0; count <10; count++){
   document.write("count": +count);
 }

// for in loop
 var books = new book("c++", "java"); 
 
 for (book in books){
   console.log(book)
 }
 
 var books = new book(); 
 book = {title: "c++", title: "java"};
 for (title in book){
   console.log(title)
 }
 
// loop control
   var x = 1;
         document.write("Entering the loop<br /> ");
         
         while (x < 20)
         {
            if (x == 5){
               break; // breaks out of loop completely
            }
            x = x + 1;
            document.write( x + "<br />");
            if (x >= 5){
              // continue skip rest of loop
            }
         }
         
         document.write("Exiting the loop!<br /> ");
         

  
  

以上是关于javascript 所有JavaScript部件的主要内容,如果未能解决你的问题,请参考以下文章

保护 API 以与 Javascript 小部件一起使用

在现代站点中添加 SPFx webpart 时的 Javascript

javascript 构建Javascript小部件

私人JavaScript小部件

从 JavaScript 设置 Web 部件个性化属性

将 Javascript 小部件添加到单个 Tumblr 帖子