JavaScript基础(javascript变量)
程序员文章站
2022-03-02 11:53:36
...
<html>
<head>
<script type="text/javascript">
function MyFunction(){
var x = 5;
var y = 6;
var z = x + y;
document.getElementById("hello").innerHTML = z;
}
</script>
</head>
<body>
<p>Cal 5 + 6 = ?</p>
<button type = "button" onclick="MyFunction()">Click!</button>
<p id = "hello"></p>
<script type="text/javascript">
var car = new Array();
var i;
var j;
var arr = new Array("test11","test22","test33");
var testarr = {username:"name",password:"pass",type:"stu"};
car[0] = "String one";
car[1] = "String two";
car[2] = "222";
car[3] = "String three";
for(i = 0 ; i < car.length ; i++){
document.write(car[i]+",");
}
document.write("</br>");
for(j = 0 ; j < arr.length ; j++){
document.write(arr[j]+",")
}
document.write(testarr.username);
document.write(testarr["password"]);
</script>
</body>
</html>
转载于:https://my.oschina.net/passer007/blog/602570
推荐阅读
-
JavaScript实现拖放事件
-
javascript自定义in_array()函数实现方法_javascript技巧
-
Javascript学习笔记二 之 变量_基础知识
-
Node.js实战 建立简单的Web服务器_javascript技巧
-
如何提高javascript加载速度
-
解析JavaScript实现DDoS攻击原理与保护措施
-
JavaScript 宝典(第7 版)
-
利用JavaScript更改input中radio和checkbox样式
-
Google排名中的10个最著名的 JavaScript库_javascript技巧
-
IE浏览器中图片onload事件无效的解决方法_javascript技巧