JavaScript: Data Structures

 

 

// JavaScript Document  
// file:1.js
// edit: geovindu, Geovin Du
/*var GeovinDu = {
   firstName: "Geovin", 
   lastName: "Du"
};

var student1 = {
   id: "12345678",
   courses: ["Programming I", "English II", "Chinese"],
   advised: false
};

console.log(GeovinDu.lastName); // displays "Du"
console.log(student1["id"]); // displays "12345678"
console.log(student1.courses[1]); displays "English II"
student1.advised = true;
GeovinDu.age = 50;*/
$(document).ready(function () {	
	
function Person(first, middle, last) {
   this.first = first;
   this.middle = middle;
   this.last = last;
   this.initials = initials;
}
	
function CNPerson(sumname, realname, age,sex) {
   this.sumname = sumname;
   this.realname = realname;
   this.age = age;
   this.sex=sex;
   this.gender = gender;
}

	
function gender()
{
		//暂时,以一个处理,不以数组处理
		var cn="";
		if(this.age>=18 && this.sex=="女")
		{
			cn="小姐";
		}
		if(this.age>=30 && this.sex=="女")
		{
			cn= "女士";
		}
		if(this.age>=18 && this.sex=="男")
		{
			cn= "先生";
		}
		if(this.age>=30 && this.sex=="男")
		{
			cn="先生";
		}
	return cn;
}
	
function initials() {
   //取第一个字母
   return this.first[0] + this.middle[0] + this.last[0];
}

var aPerson = new Person("Du","King","Geovin");
console.log("First name: " + aPerson.first);
console.log("Middle name: " + aPerson.middle);
console.log("Last name: " + aPerson.last);
console.log("Initials: " + aPerson.initials());	
	
	
var cPerson=new CNPerson("涂","聚文",25,"男");
console.log("姓:"+cPerson.sumname);
console.log("名:"+cPerson.realname);
console.log("年龄:"+cPerson.age);
console.log("性别:"+cPerson.sex);
//cPerson.gender=gender();
//console.log(cPerson.gender);
console.log("称呼:"+cPerson.gender())
	
$("#sumname").html(cPerson.sumname);
$("#realname").html(cPerson.realname);
$("#age").html(cPerson.age);
$("#sex").html(cPerson.sex);
$("#gender").html(cPerson.gender());	
});
	

  

 

调用:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">	
<title>Data Structures & Algorithms with JavaScript </title>
	<meta name="Description" content="geovindu,涂聚文,Geovin Du"/>
<meta name="Keywords" content="geovindu,涂聚文,Geovin Du"/>
<meta name="author" content="geovindu,涂聚文,Geovin Du"/>	
<script  src="js/jquery-3.6.0.js"></script>
<script type="text/javascript" src="data/1.js"></script>	
</head>

<body>
<div id="sumname">du</div>
<div id="realname">geovin</div>
<div id="age"></div>
<div id="sex"></div>
<div id="gender"></div>	

</body>
</html>

  

 

 

Agile Principles, Patterns, and Practices in C#

https://github.com/aclimarin/AgilePrinciplesPatternsAndPractices
https://github.com/donaldnevermore/agile-principles

Java
https://github.com/kwon37xi/AgileSoftwareDevelopmentPrinciplesPatternsAndPractices
https://github.com/oneils/agile-principles-example


Data Structures & Algorithms with JavaScript
by Michael McMillan
https://www.oreilly.com/library/view/data-structures-and/9781449373931/
https://github.com/oreillymedia/data_structures_and_algorithms_using_javascript

Learning JavaScript Data Structures and Algorithms, Third Editon
https://github.com/PacktPublishing/Learning-JavaScript-Data-Structures-and-Algorithms-Third-Edition
https://www.oreilly.com/library/view/learning-javascript-data/9781788623872/

C Programming: A Modern Approach 2and Edition
by K.N.King
https://github.com/fordea/c-programming-a-modern-approach
https://www.wiley.com/en-au/C+Programming%3A+A+Modern+Approach%2C+2nd+Edition-p-9780393979503
https://www.ituring.com.cn/book/2947
https://www.ituring.com.cn/book/2947

 

posted @ 2023-09-29 20:32  ®Geovin Du Dream Park™  阅读(13)  评论(0)    收藏  举报