console.log("Hi World!");document.write("hi <br />");var str = "string type";var intType = 0;var boolType = true;var arrayType = [];var objectType = {};arrayType = [1, 2, 3];var arrayNote = new Array(1, 2, 3);document.write(arrayType[0] + '<br />');var arraySparsed = new Array();arraySparsed[5] = "defined";document.write(arraySparsed + '<br />');arrayType = [str, intType, boolType];document.write(arrayType + '<br />');var myStack = [];myStack.push(str);myStack.push(intType);myStack.push(boolType);document.write("my current stack: " + myStack + '<br />')document.write("Pop element: " + myStack.pop() + '<br />')document.write("my current stack after pop: " + myStack + '<br />')document.write("Stack before shift: " + myStack + '<br />');document.write("shifted: " + myStack.shift() + '<br />')document.write("my stack now: " + myStack + '<br />');document.write("Using unshift to add cat to the stack " + '<br /');myStack.unshift('cat')document.write(myStack + '<br /');<!doctype html><html><head> <meta charset="utf-8"> <title>JSDemo</title> <meta name="My attempt to learn JS in a day" content="My attempt."> <meta name="Ian Brown" content="SitePoint"> <link rel="stylesheet" href="css/styles.css?v=1.0"></head><body> <script src="script.js"></script></body></html>在上面,我可以运行所有内容,直到“使用 unshift 将 cat 添加到堆栈”之后,或者myStack.unshift('cat') document.write(myStack+'<br /');是否有太多换行符?我需要扩展页面吗?不知道该怎么做,希望得到一些帮助!
添加回答
举报
0/150
提交
取消