JavaScrip入门-变量计算%函数
生活随笔
收集整理的這篇文章主要介紹了
JavaScrip入门-变量计算%函数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
哈
<html> <body> <script>var hello="Hello ";hello=hello+" world!";var age1=16+1;var age2=20var 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
總結
以上是生活随笔為你收集整理的JavaScrip入门-变量计算%函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 近期热门微信小程序demo源码下载汇总
- 下一篇: 从零开始学习编程