JavaScrip入门-变量&计算%函数

<html>
<body>
<script>
  var hello="Hello ";
  hello=hello+" world!";
  var age1=16+1;
  var age2=20
  var ot=true; 
  document.write(hello+age1);<!--Hello world!17 因为中间空两行 -->
  document.write(age1==age2);//false
  document.write(age1 <  age2);//true
  document.write(hello >=  "Hello ");//true
 </script> 
 </body>
 </html>

定义了一个变量hello,给hello赋值

因为这是在HTML中写"Hello "+" world!"中间超过一个空格也会只显示一个

a--单独写,因为容易引起歧义。

所有逻辑运算符(!>&&与>||或)的优先级都低于关系运算符

条件/三元运算符<exp>?<v1>:<v2>

if(exp)

v1;

else

v2;

 function gcd(u,v){}

函数变量

var f=new Function("x","y","returnx*y" );等价于function f(x,y){return x*y;}

函数变量作用域只有两种:这个页面or函数内部

原文地址:https://www.cnblogs.com/Ljj-Nancy/p/5770384.html