ES6——内置对象的扩展
字符串的扩展
//模版字符串
let flag=true;
let hml=`<ul>
<li>
<span></span>
<span></span>
<span class="${flag?'show':'hide'}"></span>
</li>
</ul>`;
console.log(html);
1、repeat
let str1="a"; let str2=str1.repeat(3); console.log(str2); ///输出 aaa
2、includes() strartswith() endswith()
////是否包含,开头,结尾
let str="miaov";
console.log(str.includes("ao")); //true
console.log(str.includes("asd")); //false
console.log(str.strartswith("m")); //true
console.log(str.strartswith("o")); //false
console.log(str.endswith("ov")); //true
console.log(str.endswith("m")); //false
数组的扩展
// Array.from()
var lis=document.querySelectorAll("li");
var lis2=Array.from(lis);
console.log(lis2); //输出数组
console.log(Array.isArray(lis2)); //true
// find() , findIndex()
const arr=[1,2,3,4];
let res=arr.find(function(a){
return a<2;
})
console.log(res); ///输出 undefined;
//fill();
const arr=[1,2,3,4];
arr.fill("abc",1,3);
console.log(arr); ///输出 1,abc,abc,4
以上。
ES6——内置对象的扩展的更多相关文章
- ES6新增语法和内置对象(let,const, Array/String/Set 扩展方法(解构赋值,箭头函数,剩余参数))
1.let ES6中新增的用于声明变量的关键字. let 声明的变量只在所处于的块级有效. 注意:使用 let 关键字声明的变量才具有块级作用域,var 关键字是不具备这个特点的. 1. 防止循环变量 ...
- 深入浅出ES6的标准内置对象Proxy
Proxy是ES6规范定义的标准内置对象,可以对目标对象的读取.函数调用等操作进行拦截.一般来说,通过Proxy可以让目标对象"可控",比如是否能调用对象的某个方法,能否往对象添加 ...
- JS高级——扩展内置对象的方法
基本概念 内置对象有很多,几个比较重要的:Math.String.Date.Array 基本使用 1.内置对象创建出来的对象使用的方法使用的其实都是内置对象的原型对象中的方法 (1)a并没有charA ...
- Javascript初识之流程控制、函数和内置对象
一.JS流程控制 1. 1.if else var age = 19; if (age > 18){ console.log("成年了"); }else { console. ...
- JavaScript之函数,词法分析,内置对象和方法
函数 函数定义 JavaScript中的函数和Python中的非常类似,只是定义方式有点区别. // 普通函数定义 function f1() { console.log("Hello wo ...
- Js基础知识7-JavaScript所有内置对象属性和方法汇总
对象什么的,程序员可是有很多呢... JS三大对象 对象,是任何一个开发者都无法绕开和逃避的话题,她似乎有些深不可测,但如此伟大和巧妙的存在,一定值得你去摸索.发现.征服. 我们都知道,JavaScr ...
- 你不知道的JavaScript(五)内置对象模版
尽管JavaScript中有对象的概念,但一般我们并不说JavaScript是面向对象的编程语言,因为它不具备面向对象的一些最基本特征. 在c++/Java等这些面向对象的编程语言中,我们要定义一个对 ...
- .Net的内置对象之一 Request
一.Request简介 Request对象是.net的内置对象之一,也是.net中常用的对象,用于获取客户端的信息,可以使用Request对象访问任何基于HTTP请求传递的所有信息.通过Request ...
- 170104、js内置对象与原生对象
内置对象与原生对象 内置(Build-in)对象与原生(Naitve)对象的区别在于:前者总是在引擎初始化阶段就被创建好的对象,是后者的一个子集:而后者包括了一些在运行过程中动态创建的对象. 原生对象 ...
随机推荐
- pycharm中使用redis模块入门
数据缓存系统:1:mongodb:是直接持久化,直接存储于硬盘的缓存系统2:redis: 半持久化,存储于内存和硬盘3:memcache:数据只能存储在内存里的缓存系统 redis是一个key-val ...
- django-渲染页面+locals
from django.shortcuts import render, redirect from django.views import View from django.http import ...
- Numpy的ndarry:一种多维数组对象
Numpy的ndarry:一种多维数组对象 Numpy最重要的一个特点就是其N维数组对象(即ndarry),该对象是一个快速而灵活的大数据集容器.你可以利用这种数组对整块数据执行一些数学运算,其语法跟 ...
- leetcode14
public class Solution { public string LongestCommonPrefix(string[] strs) { ) { return ""; ...
- 「小程序JAVA实战」小程序的视频点赞功能开发(62)
转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudeshipindianzangongnengkaifa61/ 视频点 ...
- FireDAC 之FDMetaInfoQuery
FDMetaInfoQuery http://docs.embarcadero.com/products/rad_studio/firedac/frames.html http://docwiki.e ...
- 跟我学算法- tensorflow模型的保存与读取 tf.train.Saver()
save = tf.train.Saver() 通过save. save() 实现数据的加载 通过save.restore() 实现数据的导出 第一步: 数据的载入 import tensorflo ...
- 30. Substring with Concatenation of All Words (String; HashTable)
You are given a string, s, and a list of words, words, that are all of the same length. Find all sta ...
- c语言字符串指针
最近正在看c语言,在指针这块遇到了麻烦,特别是字符串指针这块,简单记录下. 字符串指针 void main() { char *p = "tasklist"; printf(&qu ...
- 通过HttpWebRequest实现模拟登陆
1>通过HttpWebRequest模拟登陆 using System; using System.Collections.Generic; using System.Linq; using S ...