一道面试题:传递两个参数m,n,返回长度为m,所有元素都为n的数组,要求不能用循环。
利用函数的递归和 concat() 方法可以实现,代码如下:
function fn(m, n) { return m ? fn(m - 1, n).concat(n) : []; }
1、给 input 文本框和 textarea 多行文本框添加发光焦点响应特效
input[type=text], textarea { -webkit-transition: all 0.30s ease-in-out; -moz-transition: all 0.30s ease-in-out; -ms-transition: all 0.30s ease-in-out; -o-transition: all 0.30s ease-in-out; outline: none; padding: 3px 0px 3px 3px; margin: 5px 1px 3px 0px; border: 1px solid #ddd; } input[type=text]:focus, textarea:focus { box-shadow: 0 0 5px rgba(81, 203, 238, 1); padding: 3px 0px 3px 3px; margin: 5px 1px 3px 0px; border: 1px solid rgba(81, 203, 238, 1); }
尝试一下 »
2、可以使用 resize: none; 来禁用 textarea 右下角的拖动图标。
textarea { resize: none; }
3、只是固定大小,右下角的拖动图标仍在:
textarea { width: 200px; height: 100px; max-width: 200px; max-height: 100px; }
window.location.assign(url) : 加载 URL 指定的新的 HTML 文档。就相当于一个链接,跳转到指定的url,当前页面会转为新页面内容,可以点击后退返回上一个页面。
window.location.replace(url) : 通过加载 URL 指定的文档来替换当前文档,这个方法是替换当前窗口页面,前后两个页面共用一个窗口,所以是没有后退返回上一页的
var url = 'http: //www.a.com/index.php?route=main&nav&user=tom&id=123&profile';
var querys = url
.substring(url.indexOf('?') + 1)
.split('&')
.map((query) => query.split('='))
.reduce((params, pairs) => (params[pairs[0]] = pairs[1] || '', params), {});
console.log(querys);
window.location.href和window.location.hash的区别
window.location.href表示重定向 是完整的url地址
window.location.href
是完整的url 比如window.location.href="should be shared”表示的是重新定向 页面跳转到新的页面
可以通过window.location.href得到a标签的完整的href 比如<a href="#book">
使用href 得到完整的链接 url
window.location.hash
锚链接 相比如href 通过window.location.hash
不会跳转到新的链接 只会在当前链接里面改变锚链
<a href="#book">通过window.location.hash得不到完整的链接 URL
仅仅得到#book
感谢您的支持,我会继续努力的!
支付宝扫一扫,即可进行扫码打赏哦
2513允许你向数组对象添加属性或方法 Array 对象方法 方法 描述 concat()
一道面试题:传递两个参数m,n,返回长度为m,所有元素都为n的数组,要求不能用循环。
利用函数的递归和 concat() 方法可以实现,代码如下:
2512textarea
1、给 input 文本框和 textarea 多行文本框添加发光焦点响应特效
尝试一下 »
2、可以使用 resize: none; 来禁用 textarea 右下角的拖动图标。
3、只是固定大小,右下角的拖动图标仍在:
2511Location 对象
window.location.assign(url) : 加载 URL 指定的新的 HTML 文档。就相当于一个链接,跳转到指定的url,当前页面会转为新页面内容,可以点击后退返回上一个页面。
window.location.replace(url) : 通过加载 URL 指定的文档来替换当前文档,这个方法是替换当前窗口页面,前后两个页面共用一个窗口,所以是没有后退返回上一页的
2210JavaScript reduce() 方法
var url = 'http: //www.a.com/index.php?route=main&nav&user=tom&id=123&profile';
var querys = url
.substring(url.indexOf('?') + 1)
.split('&')
.map((query) => query.split('='))
.reduce((params, pairs) => (params[pairs[0]] = pairs[1] || '', params), {});
console.log(querys);
857Location 对象
window.location.href和window.location.hash的区别
window.location.href表示重定向 是完整的url地址
window.location.href
是完整的url 比如window.location.href="should be shared”表示的是重新定向 页面跳转到新的页面
可以通过window.location.href得到a标签的完整的href 比如<a href="#book">
使用href 得到完整的链接 url
window.location.hash
锚链接 相比如href 通过window.location.hash
不会跳转到新的链接 只会在当前链接里面改变锚链
<a href="#book">通过window.location.hash得不到完整的链接 URL
仅仅得到#book