1
问题
每当我打电话arrayGuide
我得到一个error
如何通过原型传递多维数组?
Array.prototype.arrayGuide = function() {
console.log(this) // When called… this should be getting logged.
}
//How to get this prototype to work
replace = {
basic: {
stage1: {
one: ["hello", "world"],
two: ["brother", "sister"],
three: ["baby", "adult"]
},
stage2: {
one: ["1"],
two: ["2"],
three: ["3"]
}
},
advanced: {
humans: [/^biology\s/gi, /science$/i]
}
}
replace.arrayGuide() // This keeps throwing an error message
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
结果我应该得到
我应该从第一个演示中获得这些结果。但由于某种原因,我不是。
function arrayRegExpCreator(place) {
console.log(place) // I should be getting this…
}
replace = {
basic: {
stage1: {
one: ["hello", "world"],
two: ["brother", "sister"],
three: ["baby", "adult"]
},
stage2: {
one: ["1"],
two: ["2"],
three: ["3"]
}
},
advanced: {
humans: [/^biology\s/gi, /science$/i]
}
}
arrayRegExpCreator(replace)
值得一提的是,原生对象的原型是不能修改的从未延长原生对象的原型,如果它不是一个填充工具 – Voreny