初识Javascript

<head>

<meta charset="utf-8"/>

<title></title>

<script>

js代码内部引入方法1

alert('iiii')

alert('1234')

</script>

</head>

 

<body>

js代码内部引入方法2

<script type='text/javascript'>

alert('李青是猪🐖');

</script>

 

外部引入

<scrtpt src="script/js/名称.js" type="text/javascript" charset="utf-8"></script>

 

<noscript>

您的浏览器不支持javascript,请更换查看

</noscript>

 

行内引入

<a href="javascript:confirm('您确认要学习Javascript吗?');">报名</a>

<p onclick="javascript:alert('hello word');">clickMe</p>

 

以上是引入方式

 

<script type="text/javascript">

 

var a;

var b;

var c,d;

 

var test = 'this is a test';

var test1 = '12';

var test2 = 1.2;

var test3 = true;

var test4 = false;

 

var a = b = c = d = e = 1;

 

a=33;

 

var username = 'king';

var userName = 'QUEEN';

 

var age = 12;

var test5 = 'hello';

var _test = 'hello';

 

 

document.write('aaa');

document.write('<br />');

document.write('bbb');

alert('<h1>rrrrrr</h1>')

document.write('ccc');

document.write('ddd');

document.write('<br />');

document.write('hello \

world');\

 

变量名称最好含义明确,以字母或者下划线开头,跟上数字字母下划线

var age=12;

var test5= 'hello';

var 12a='bb';

alert(12a);

var _test='hello';

alert(_test);

 

驼峰标记法和下划线

var firstName = 'king';//小驼峰

var FirstName = 'queen';//大驼峰

var first_name = 'ymt';//下划线法

 

 

 

console.log('向控制台中书写内容');

</script>

 

 

 

 

 

a = 0;

a = 0.0;

a = 0/0;

//alert(a);   //not a number

//NaN

a = NaN;

//alert(typeof Number(NaN));

 

var a ="";//空字符集->false

//a=0;

//a= null;

var b=0;

console.log( a  ==   b);

 

//null  !=  0

//null  !=  ""

//null  ==  undefined

//0  !=  undefined

//" " !=  undefined

//" " ==  0 

 

posted @ 2019-08-12 19:43  不知名网友  阅读(126)  评论(0编辑  收藏  举报