码迷,mamicode.com
首页 > 其他好文 > 详细

1212课后随笔

时间:2019-12-16 12:52:45      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:cron   class   html   script   ||   --   逻辑运算符   lin   ret   

1、数据类型转换

    Number()---字符串转数值,有数字外其他字符时显示:NaN;

    转整数类型:parseInt();截取其他字符前的所有数字;

    转浮点类型:parseFloat();截取其他字符前的所有数字;

    判断是否是数字类型:isNaN();

    String()---把数字 / 布尔类型转换成字符串;

    toString()---数字 / 布尔类型转换成字符串;

2、运算符:

    算数运算符:+ 、- 、* 、/ 、% 、++ 、-- ;

    赋值运算符:= 、+= 、-= 、*= 、/= 、%= ;

    比较运算符:== 、!= 、> 、< 、>= 、<= ;

//获取数组中最大值[12,34,54,4,7,23,45];
var arr = [12,34,54,4,7,23,45];
function getMaxMin(arr,maxmin){
  if(maxmin === "max"){
    return Math.max.apply(Math,arr);
  }else if(maxmin === "min"){
    return Math.min.apply(Math,arr);
  }
}
var a = getMaxMin(arr,"max");
//最大值
console.log(a);
var b = getMaxMin(arr,"min");
//最小值
console.log(b);

    10 == ‘10’    ==值相等即可    ===表示值相等,并且类型也相等;

    逻辑运算符:&& 、|| 、!

    三元运算符:?:--------------例如true?value1:value2;

3、函数

    通过function关键词进行定义,气候是函数名和括号()

    function fun(arg1,arg2){

    }

    运行:fun(arg)

    返回值:return

    var a = fun(arg);

4、常见的HTML事件属性

    <div onclick=”func()”></div>    onchange的标签:

        <input type="text">,<select>,<textarea>

    支持onload的HTML标签有:

        window.onload()=function(){}    

        <body>,<frame>,<frameset>,<iframe>,<img>,<link>,<script>

    onblur:失去焦点事件:onfocus:获取焦点事件;

        <a>,<acronym>,<address>,<area>,<b>,<bdo>,<big>,<blockquote>,

        <button>,<caption>,<cite>,<dd>,<del>,<dfn>,<div>,<dl>,<dt>,<em>,

        <fieldset>,<form>,<frame>,<frameset>,<h1>to<h6>,<hr>,<i>,

        <iframe>,<img>,<input>,<ins>,<kbd>,<label>,<legend>,<li>

        <object>,<ol>,<p>,<pre>,<q>,<samp>,<select>,<small>,<span>,

         <strong>,<sub>,<sup>,<table>,<tbody>,<td>,<textarea>,<tfoot>,

        <th>,<thead>,<tr>,<tt>,<ul>,<var>

1212课后随笔

标签:cron   class   html   script   ||   --   逻辑运算符   lin   ret   

原文地址:https://www.cnblogs.com/ltl11230/p/12048480.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!