Vue.js check variable is array or object
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script> </head> <body> <div id="app"> <p>Result 1 = {{result1}}</p> <p>Result 2 = {{result2}}</p> <button @click="myFunction()">Click Me</button> </div> <script> new Vue({ el: '#app', data: { array1: [1, 9, 10], obj1: {type:"Fiat", model:"800"}, result1:'', result2:'' }, methods:{ myFunction: function () { this.result1 = Array.isArray(this.array1); this.result2 = this.obj1 instanceof Object; } } }); </script> </body> </html>
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script> </head> <body> <div id="app"> <p>Result 1 = {{result1}}</p> <p>Result 2 = {{result2}}</p> <button @click="myFunction()">Click Me</button> </div> <script> new Vue({ el: '#app', data: { array1: [1, 9, 10], obj1: {type:"Fiat", model:"800"}, result1:'', result2:'' }, methods:{ myFunction: function () { this.result1 = Array.isArray(this.array1); this.result2 = this.obj1 instanceof Object; } } }); </script> </body> </html>
Copyrights@tutorialsplane.com