JavaScriptでオブジェクトの配列のプロパティにアクセスするにはどうすればよいですか?
オブジェクトの配列のプロパティにアクセスするには、次のコードを実行してみてください-
例
<html>
<head>
<title>User-defined objects</title>
<script>
function book(title, author){
this.title = title;
this.author = author;
}
</script>
</head>
<body>
<script>
var myBook = new book("PHP", "Amit");
book.prototype.price = null;
myBook.price = 250;
document.write("Book title is : " + myBook.title + "<br>");
document.write("Book author is : " + myBook.author + "<br>");
document.write("Book price is : " + myBook.price + "<br>");
</script>
</body>
</html> 出力
Book title is : PHP Book author is : Amit Book price is : 250
-
JavaScriptでIDごとにオブジェクトの配列をグループ化する方法は?
以下は、JavaScriptでオブジェクトの配列をIDでグループ化するコードです- 例 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style>
-
JavaScriptでオブジェクトを含む配列の配列をループするにはどうすればよいですか?
以下は、JavaScriptのオブジェクトを含む配列の配列をループするコードです- 例 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style>