Created
December 3, 2015 05:42
-
-
Save urstory/e9a9eaf3c4765eb01be6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
function Queue(){ | |
this.data = []; | |
this.add = function(d){ | |
this.data.push(d); | |
}; | |
this.get = function(){ | |
var d = this.data[0]; | |
// 0번째 위치한 1건 삭제. | |
this.data.splice(0,1); | |
return d; | |
}; | |
this.size = function(){ | |
return this.data.length; | |
}; | |
} | |
var queue = new Queue(); | |
queue.add('hello'); | |
alert(queue.size()); | |
queue.add('hi'); | |
alert(queue.size()); | |
queue.add('javascript'); | |
alert(queue.size()); | |
alert(queue.get()); | |
alert(queue.size()); | |
alert(queue.get()); | |
alert(queue.size()); | |
alert(queue.get()); | |
alert(queue.size()); | |
alert(queue.get()); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment