Java编程

慕课网初识javascript

js输出window.alert() 警告框document.write() 写到HTML文档中innerHTML 写到HTML元素console.log() 写到浏览器的控制台js输出

慕课网初识javascript

js语句与注释分号javaScript 代码javaScript 语句标识符代码块单行和多行注释js语句与注释js数据类型字符串(String)数字(Number)布尔(Boolean)数组(Array)对象(Object)空(Null)未定义(Undefined)js数据类型js变量变量必须以字母开头变量也能以 $ 和 _ 符号开头(不过我们不推荐这么做)变量名称对大小写敏感(y 和 Y 是不同的变量)js函数函数是由事件驱动的或者当它被调用时执行的可重复使用的代码块function a( 参数 ){} 声明会前置var a = function( 参数 ){} 匿名函数函数中的 returnjs函数运算符赋值运算符 = += -= 等算术运算符 + – * / 等字符串的 + 运算符js运算符js比较与逻辑运算符< 小于> 大于**== 等于 1 == ‘1’ **=== 绝对等于(值和类型均相等)!= 不等于&& and。

js杈撳嚭window.alert() 璀﹀憡妗?/li>document.write() 鍐欏埌HTML鏂囨。涓?/li>innerHTML 鍐欏埌HTML鍏冪礌console.log() 鍐欏埌娴忚鍣ㄧ殑鎺у埗鍙?/li>js杈撳嚭

js璇彞涓庢敞閲?/h2>鍒嗗彿javaScript 浠g爜javaScript 璇彞鏍囪瘑绗?/li>浠g爜鍧?/li>鍗曡鍜屽琛屾敞閲?/li>js璇彞涓庢敞閲?lt;/title></head><body><script type="text/javascript">/**- 鍒嗗彿- javaScript 浠g爜- javaScript 璇彞鏍囪瘑绗?var if for- 浠g爜鍧? - 鍗曡鍜屽琛屾敞閲? **/var a=1// 浠g爜鍧? function b(){var c=1;var d=2;}//鍗曡娉ㄩ噴/*澶氳娉ㄩ噴*/</script></body></html>js鏁版嵁绫诲瀷瀛楃涓诧紙String锛?/li>鏁板瓧锛圢umber锛?/li>甯冨皵锛圔oolean锛?/li>鏁扮粍锛圓rray锛?/li>瀵硅薄锛圤bject锛?/li>绌猴紙Null锛?/li>鏈畾涔夛紙Undefined锛?/li><!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>js鏁版嵁绫诲瀷js鍙橀噺鍙橀噺蹇呴』浠ュ瓧姣嶅紑澶?/li>鍙橀噺涔熻兘浠?$ 鍜?_ 绗﹀彿寮€澶达紙涓嶈繃鎴戜滑涓嶆帹鑽愯繖涔堝仛锛?/li>鍙橀噺鍚嶇О瀵瑰ぇ灏忓啓鏁忔劅锛坹 鍜?Y 鏄笉鍚岀殑鍙橀噺锛?/li>js鍑芥暟鍑芥暟鏄敱浜嬩欢椹卞姩鐨勬垨鑰呭綋瀹冭璋冪敤鏃舵墽琛岀殑鍙噸澶嶄娇鐢ㄧ殑浠g爜鍧?/li>function a( 鍙傛暟 ){} 澹版槑浼氬墠缃?/li>var a = function( 鍙傛暟 ){} 鍖垮悕鍑芥暟鍑芥暟涓殑 returnjs鍑芥暟杩愮畻绗?/h2>璧嬪€艰繍绠楃 = += -= 绛?/li>绠楁湳杩愮畻绗?+ – * / 绛?/li>瀛楃涓茬殑 + 杩愮畻绗?/li>js杩愮畻绗?lt;/title></head><body><script type="text/javascript">/ 璧嬪€艰繍绠楃 = += -= 绛? 绠楁湳杩愮畻绗? + - * / 绛? 瀛楃涓茬殑 + 杩愮畻绗?*/var a = 1; //璧嬪€? a += 3; // a = a + 3;console.log(a); //4var b = 2;b = b * 3;console.log(b); //6var c = 'hello';var d = 'world';var e = c + d;console.log(e); //helloword</script></body></html>js姣旇緝涓庨€昏緫杩愮畻绗?/h2>< 灏忎簬> 澶т簬**== 绛変簬 1 == 鈥?鈥?**=== 缁濆绛変簬锛堝€煎拰绫诲瀷鍧囩浉绛夛級!= 涓嶇瓑浜?/li>&& and。</p> <p>var arr = [1,2,3,4,5];console.log(arr.filter(value => value%2 == 0));。</p> <p>var arr = [1,2]; var arr1 =arr; arr = [1,3]; document.write(arr1)。</p> <p>* 解构:快捷,方便** 对象解构*/{var expense = {type: “es6”,amount: “45”};//1.ES5// var type = expense.type;// var amount = expense.amount;// console.log(type, amount); //output: es6 45//2.ES6const { type, amount, abc } = expense;console.log(type, amount, abc); //output: es6 45 undefined}{var saveFiled = {extension: “jpg”,name: “girl”,size: 14040};//ES5function fileSammary1(file) {return `${file.name}.${file.extension}的总大小是${file.size};`}//ES6//名字不能变,位置可以乱function fileSammary2({ name, size, extension }) {return `${name}.${extension}的总大小是${size};`}console.log(fileSammary1(saveFiled)); //output: girl.jpg的总大小是14040;console.log(fileSammary2(saveFiled)); //output: girl.jpg的总大小是14040;}数组的解构。</p> <p>obj.a ===undefined ,因为 undefined == null 值为true// 这是 JQuery 中推荐的写法, 其余情况全部用 === (避免代码风险有代码洁癖)}3. JS 中有哪些内置函数4. JS 变量按照存储方式区分为哪些类型,并描述其特点5. 如何理解 JSON知识点变量类型:值类型 和 引用类型(指针)引用类型包括: 数组 函数 对象;引用类型公共空间,是指针var a=100;var b=a;a=200;console.log(b) //100var a={age:20};var b=a;b.age=21;console.log(a.age) //21typeof只能区分值类型的详细类型,对引用类型无能为力,但可以区分出函数来typeof undefined;//undefinedtypeof ‘abc’;//stringtypeof 123;//numbertypeof true;//booleantypeof {};//objecttypeof [];//objecttypeof null;//objecttypeof console.log//function强制类型转换(值类型的计算)。</p> <p>var obj = {};obj.log = console.log;obj.log.call(console,this);该代码在浏览器中执行,输出的日志结果是什么?undefinedwindowconsoleobj。</p> </div><!-- .entry-content --> </article><!-- #post-4168 --> <div class="clearfix"></div> <ul class="default-theme-post-navigation"> <li class="theme-nav-previous"><a href="https://www.dershi.cn/4166.html" rel="prev"><span class="meta-nav">←</span> 圣思园精通springboot</a></li> <li class="theme-nav-next"><a href="https://www.dershi.cn/4170.html" rel="next">开课吧大数据全站分析师课程 <span class="meta-nav">→</span></a></li> </ul> <div class="clearfix"></div> <h3 class='comment-reply-title'>Similar Posts</h3> <div class="mb-related-posts mb-simple-featured-posts mb-simple-featured-posts-wrap row"> <article class="mb-featured-article col-md-4 px-lg-3 post"> <a class="post-thumbnail" href="https://www.dershi.cn/1835.html" aria-hidden="true" tabindex="-1"> <img width="450" height="300" src="https://www.dershi.cn/wp-content/uploads/hrgwh9re.jpg" class="attachment-magazinebook-featured-image-medium size-magazinebook-featured-image-medium wp-post-image" alt="" loading="lazy" srcset="https://www.dershi.cn/wp-content/uploads/hrgwh9re.jpg 450w, https://www.dershi.cn/wp-content/uploads/hrgwh9re-300x200.jpg 300w" sizes="(max-width: 450px) 100vw, 450px" /> </a> <span class="cat-links"><a href="https://www.dershi.cn/java" rel="category tag">Java编程</a></span> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/1835.html" rel="bookmark">千锋软件测试学习分为哪几个阶段</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-featured-article col-md-4 px-lg-3 post"> <a class="post-thumbnail" href="https://www.dershi.cn/5470.html" aria-hidden="true" tabindex="-1"> <img width="450" height="300" src="https://www.dershi.cn/wp-content/uploads/hq8mhodb.jpg" class="attachment-magazinebook-featured-image-medium size-magazinebook-featured-image-medium wp-post-image" alt="" loading="lazy" srcset="https://www.dershi.cn/wp-content/uploads/hq8mhodb.jpg 450w, https://www.dershi.cn/wp-content/uploads/hq8mhodb-300x200.jpg 300w" sizes="(max-width: 450px) 100vw, 450px" /> </a> <span class="cat-links"><a href="https://www.dershi.cn/java" rel="category tag">Java编程</a></span> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/5470.html" rel="bookmark">黑马程序员训练营javaee</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-featured-article col-md-4 px-lg-3 post"> <span class="cat-links"><a href="https://www.dershi.cn/java" rel="category tag">Java编程</a></span> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/27.html" rel="bookmark">马士兵java视频全集下载</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> </div> <div id="comments" class="comments-area"> <div id="respond" class="comment-respond"> <h3 id="reply-title" class="comment-reply-title">发表评论 <small><a rel="nofollow" id="cancel-comment-reply-link" href="/4168.html#respond" style="display:none;">取消回复</a></small></h3><form action="https://www.dershi.cn/wp-comments-post.php" method="post" id="commentform" class="comment-form" novalidate><p class="comment-notes"><span id="email-notes">邮箱地址不会被公开。</span> 必填项已用<span class="required">*</span>标注</p><p class="comment-form-comment"><label for="comment">评论</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p><p class="comment-form-author"><label for="author">名称 <span class="required">*</span></label> <input id="author" name="author" type="text" value="" size="30" maxlength="245" required='required' /></p> <p class="comment-form-email"><label for="email">电子邮件 <span class="required">*</span></label> <input id="email" name="email" type="email" value="" size="30" maxlength="100" aria-describedby="email-notes" required='required' /></p> <p class="comment-form-url"><label for="url">站点</label> <input id="url" name="url" type="url" value="" size="30" maxlength="200" /></p> <p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" /> <label for="wp-comment-cookies-consent">在此浏览器中保存我的姓名、电子邮件和站点地址。</label></p> <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="发表评论" /> <input type='hidden' name='comment_post_ID' value='4168' id='comment_post_ID' /> <input type='hidden' name='comment_parent' id='comment_parent' value='0' /> </p></form> </div><!-- #respond --> </div><!-- #comments --> </main><!-- #main --> </div><!-- #primary --> <div class="col-md-3 px-lg-3 "> <aside id="secondary" class="widget-area"> <section id="search-2" class="widget widget_search"><h5 class="widget-title">快速搜索</h5><form action="https://www.dershi.cn/" class="search-form searchform clearfix" method="get"> <div class="search-wrap"> <input type="text" placeholder="Search" class="s field" name="s"><button class="search-icon" type="submit"><i class="fas fa-search"></i></button> </div> </form><!-- .searchform --> </section><section id="magazinebook_recent_posts_style_1_widget-6" class="widget mb-widget-recent-posts-style-1"> <div class="mb-recent-posts-style-1"> <div class="mb-recent-style-1-title"> <h5 class="widget-title">最新文章</h5> </div> <div class="mb-recent-posts-style-1-wrap"> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6545.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/_48j0bfm-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6545.html" rel="bookmark">传智播客35期java</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6543.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/howhau9d-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6543.html" rel="bookmark">网易云音乐社招java面试记录</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6539.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/hu6cz8c_-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6539.html" rel="bookmark">美国著名人工智能之父图灵</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6535.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/1qax36na-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6535.html" rel="bookmark">求贪心学院nlp第5期课程</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6533.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/ag0sqirv-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6533.html" rel="bookmark">黑马python软件培训班</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6531.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/jxvfex2m-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6531.html" rel="bookmark">牛客网刷java题目总结三</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6525.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/8co4cfwl-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6525.html" rel="bookmark">算法和数据结构慕课网</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6523.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/wvfnfcxt-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6523.html" rel="bookmark">慕课网数据分析公开课</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6521.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/ziyo_qdr-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6521.html" rel="bookmark">尚硅谷周阳springcloud笔记</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6519.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/m_6nvzmh-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6519.html" rel="bookmark">慕课网数据库设计那些事吾爱破解</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> <article class="mb-recent-article mb-rt-1-small post d-flex"> <a class="post-thumbnail" href="https://www.dershi.cn/6515.html" aria-hidden="true" tabindex="-1"> <img width="150" height="120" src="https://www.dershi.cn/wp-content/uploads/wjlrywfz-150x120.jpg" class="attachment-magazinebook-featured-image-small size-magazinebook-featured-image-small wp-post-image" alt="" loading="lazy" /> </a> <header class="entry-header"> <h3 class="entry-title"><a href="https://www.dershi.cn/6515.html" rel="bookmark">奈学教育p7架构师百度云</a></h3> <div class="entry-meta"> </div><!-- .entry-meta --> </header><!-- .entry-header --> </article> </div> </div> </section></aside><!-- #secondary --> </div> </div> </div> </div><!-- #content --> <footer id="colophon" class="site-footer"> <div class="container"> <div class="row"> <div class="col-md-12 text-center"> <div class="site-info"> <span>程序员,是在拿时间换钱,还是在编写未来。本站内容搜集整理自网络,如有侵权,请联系删除,联系邮箱:666999@mail.com </span> <span class="sep"> | </span> <span><a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">吉ICP备16006688号</a></span> <span class="sep"> | </span> <span><a href="https://www.dershi.cn/wp-sitemap.xml">sitemap</a></span> </div><!-- .site-info --> </div> </div> </div> </footer><!-- #colophon --> </div><!-- #page --> <script type='text/javascript' src='https://www.dershi.cn/wp-content/themes/magazinebook/js/navigation.js?ver=1.0.9' id='magazinebook-navigation-js'></script> <script type='text/javascript' src='https://www.dershi.cn/wp-content/themes/magazinebook/js/skip-link-focus-fix.js?ver=1.0.9' id='magazinebook-skip-link-focus-fix-js'></script> <script type='text/javascript' src='https://www.dershi.cn/wp-content/themes/magazinebook/js/jquery.easy-ticker.js?ver=3.1.0' id='magazinebook-news-ticker-js'></script> <script type='text/javascript' src='https://www.dershi.cn/wp-content/themes/magazinebook/js/splide.min.js?ver=2.3.1' id='splide-js-js'></script> <script type='text/javascript' src='https://www.dershi.cn/wp-content/themes/magazinebook/js/theme.js?ver=1.0.9' id='magazinebook-theme-js-js'></script> <script type='text/javascript' src='https://www.dershi.cn/wp-includes/js/comment-reply.min.js?ver=5.6.3' id='comment-reply-js'></script> <script type='text/javascript' src='https://www.dershi.cn/wp-includes/js/wp-embed.min.js?ver=5.6.3' id='wp-embed-js'></script> <div style="display:none;"> <script type="text/javascript" src="https://s9.cnzz.com/z_stat.php?id=1279606361&web_id=1279606361"></script> </div> </body> </html>