2019.7.20鍗侀亾js棰樼洰
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019.7.20鍗侀亾js棰樼洰相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e6%93%8d%e4%bd%9c' title='鎿嶄綔'>鎿嶄綔 nan float 鏁板瓧 result 鍐呭 nbsp ons 鍒ゆ柇
// 1銆佸0鏄庝竴涓彉閲忥紝淇濆瓨瀛︾敓鐨勫勾榫?stuAge)锛屽€间负18
var stuAge = 18;
// 2銆佸0鏄庝竴涓彉閲忥紝淇濆瓨瀛︾敓鐨勬垚缁?stuScore)锛屽€间负98.5
var stuScore = 60;
// 3銆佸0鏄庝竴涓彉閲忥紝淇濆瓨瀛︾敓鐨勫鍚?stuName)锛屽€间负寮犱笁涓?br /> var stuName = "寮犱笁涓? ;
// 4銆佸0鏄庝竴涓彉閲忥紝淇濆瓨瀛︾敓鐨勬€у埆(stuSex)锛屽€间负濂?br /> var stuSex = "濂?;
// 5銆佹墦鍗颁互涓婅緭鍏ョ殑鍙橀噺鐨勫€? 鎺у埗鍙拌緭鍑?br /> console.log(stuAge,stuScore,stuName,stuSex)
// stuName 骞撮緞 stuAge 鎬у埆 stuSex 鍒嗘暟stuscore
console.log(stuName + "骞撮緞" + stuAge + "鎬у埆" + stuSex + "鍒嗘暟" + stuScore);
// 瀵瑰彉閲忕殑鍊艰繘琛屽瓨鍙栨搷浣?br /> var num1 = 10 ;
var num2 = 20 ;
var sum = num1 + num2;//sum瀛? num1/num2鍙栧€?/p>
// 澹版槑3涓彉閲忥紝淇濆瓨姹夊牎銆侀厤椁愩€侀ギ鏂欑殑鍚嶅瓧
var humName = "棣欒荆楦¤吙鍫?,pcName = "钖潯",drinkName = "鑲ュ畢蹇箰姘?;
console.log(鈥樺椁怽鈥樺悕绉癨鈥橈細\n鈥?+ humName + 鈥榎n濂楅鍐呭锛歕n鈥?+ humName + pcName + drinkName)
var num1 = 10,num2 = 20 , stuName = 鈥榓a鈥?
//杈撳嚭 stuName + num1
var result1 = stuName + num1;
console.log(result1);
//杈撳嚭 num1 + num2
var result2 = num1 + num2;
console.log(result2);
//杈撳嚭 num1 + num2 +stuName
var result3 = num1 + num2 +stuName;
console.log(result3);
//杈撳嚭 uName + num1 +num2
var result4 = stuName + num1 +num2;
console.log(result4);
// 鍙?/2鐨勬ā
console.log(5%2);
// 鍙?/2鐨勬ā
console.log(8%2);
// 鍙?/3鐨勬ā
console.log(9%3);
// 鍙?5/50鐨勬ā
console.log(25%50);
// 杈撳嚭12鐨勫瓧绗︾被鍨?br /> num = 12 ;
console.log(typeof(num));
// 杈撳嚭浣犲ソ鐨勫瓧绗︾被鍨?br /> var str = 鈥樹綘濂解€?
// 杈撳嚭false鐨勫瓧绗︾被鍨?br /> var boo = false;
// 涓嶇粰nud璧嬪€硷紝杈撳嚭und鐨勫瓧绗︾被鍨?br /> var und;
//楠岃瘉number + string = string
result = num + str;
console.log(鈥樼粨鏋滀负锛氣€?+ result + ",绫诲瀷涓猴細" + typeof(result));
// 杈撳嚭str + boo鐨勭粨鏋滀互鍙婂瓧绗︾被鍨?
result = boo + str;
console.log(鈥樼粨鏋滀负锛氣€?+ result + ",绫诲瀷涓猴細" + typeof(result));
// 杈撳嚭str + und鐨勭粨鏋滀互鍙婂瓧绗︾被鍨?
result = str + und;
console.log(鈥樼粨鏋滀负锛氣€?+ result + ",绫诲瀷涓猴細" + typeof(result));
// 杈撳嚭num + boo鐨勭粨鏋滀互鍙婂瓧绗︾被鍨?
result = num + boo ;
console.log(鈥樼粨鏋滀负锛氣€?+ result + ",绫诲瀷涓猴細" + typeof(result));
// 杈撳嚭num + und鐨勭粨鏋滀互鍙婂瓧绗︾被鍨?
result = num + und;
console.log(鈥樼粨鏋滀负锛氣€?+ result + ",绫诲瀷涓猴細" + typeof(result));
// 鍒ゆ柇瀛楃涓?23鏄惁涓篿sNaN
console.log(isNaN(鈥?23鈥?);
// 杈撳嚭und + boo鐨勭粨鏋滀互鍙婂瓧绗︾被鍨?
result = boo + und;
console.log(鈥樼粨鏋滀负锛氣€?+ result + ",绫诲瀷涓猴細" + typeof(result));
var flag = false;
//灏唂lag杞崲涓哄瓧绗︿覆绫诲瀷
console.log(typeof flag.toString())
var n = 10;
//灏唍杞崲涓哄瓧绗︿覆绫诲瀷
console.log(typeof n.toString())
//灏?.56wesd杞崲涓烘暣鏁扮被鍨嬶紝骞惰緭鍑哄瓧绗︾被鍨?br /> console.log(parseInt("3.56wesd"),typeof parseInt("3.56wesd"));
//灏哸a3.56杞崲涓烘暣鏁扮被鍨嬶紝骞惰緭鍑哄瓧绗︾被鍨?br /> console.log(parseInt("aa3.56"),typeof parseInt("3.56wesd"));
//灏?.56wesd杞崲涓烘诞鐐圭被鍨嬶紝骞惰緭鍑哄瓧绗︾被鍨?br /> console.log(parseFloat("3.56wesd"),typeof parseFloat("3.56wesd"));
//灏哸aa杞崲涓烘诞鐐圭被鍨?br /> console.log(parseFloat("aaa"));
// 灏?.56wesd杞崲涓篘umber绫诲瀷
console.log(Number(鈥?.56wesd鈥?);
// 灏?.56杞崲涓篘umber绫诲瀷
console.log(Number(鈥?.56鈥?);
//鍦嗙殑鍗婂緞涓?锛岃绠楀嚭瀹冪殑闈㈢Нs鍜屽懆闀縧銆?br /> var r = 2;
var π = 3.14;
var s = 2*π*r;
var l = π*r*r;
console.log(鈥樺渾鐨勯潰绉槸锛氣€?+s , 鈥樺渾鐨勫懆闀挎槸锛氣€?+l);
//杈撳叆涓€涓洓浣嶆暟锛岃姹傝緭鍑哄畠鐨勬瘡涓綅涓婄殑鏁板瓧
var x = prompt(鈥樿杈撳叆4浣嶆暟瀛椻€?;
var q = x/1000;
console.log("鍗冧綅鏄細"+parseInt(q));
var b1 = x%1000;
var b = b1/100;
console.log("鐧句綅鏄細"+parseInt(b));
var s1 = x%100;
var s = s1/10;
console.log("鍗佷綅鏄細"+parseInt(s));
var g = x%10;
console.log("涓綅鏄細"+parseInt(g));
//浠?鍔犲埌100骞惰緭鍑?br /> var sum = 0;
for (var i = 0;i <= 100;i++)
sum += i
console.log("浠?鍔犲埌100鐨勭粨鏋滄槸锛?+sum)
以上是关于2019.7.20鍗侀亾js棰樼洰的主要内容,如果未能解决你的问题,请参考以下文章