console
function Person(name) {
this.name = name;
}
const f = (function() {
let p1;
return function(name) {
if(p1) {
console.log(p1.name)
return p1
} else {
return p1 = new Person(name)
}
}
})();
let person1 = new f('ww');
let person2 = new f('dd');
console.log(person1 === person2)
console.log(person1.name)
<style>
.stars {
background-color: white;
border-radius: 50%;
animation-name: twinkle;
animation-iteration-count: infinite;
}
.star-1 {
margin-top: 5%;
margin-left: 80%;
width: 5px;
height: 5px;
animation-duration: 0.5s;
}
.star-2 {
margin-top: 10%;
margin-left: 60%;
width: 6px;
height: 6px;
animation-duration: 1s;
}
.star-3 {
margin-top: 5%;
margin-left: 80%;
width: 8px;
height: 8px;
animation-duration: 1s;
}
.star-4 {
margin-top: 0%;
margin-left: 30%;
width: 10px;
height: 10px;
animation-duration: 1.5s;
}
.ball {
float: left;
width: 50px;
height: 50px;
margin-top: 5%;
margin-left: 10%;
background: linear-gradient(45deg, pink,green);
border-radius: 50%;
animation-name: ball;
animation-iteration-count: infinite;
animation-duration: 2s;
}
@keyframes ball {
100% {
margin-top: 100%;
transform: scale(0.5);
opacity: 0.5;
}
}
@keyframes twinkle {
20% {
transform: scale(0.5);
opacity: 0.5;
}
}
#back {
position: fixed;
padding: 0;
margin: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(black, #000099, #66c2ff, #ffcccc, #ffeee6);
}
</style>
<div id="back"></div>
<div class="ball"></div>
<div class="star-1 stars"></div>
<div class="star-2 stars"></div>
<div class="star-3 stars"></div>
<div class="star-4 stars"></div>
.box {
width: 376px;
height: 182px;
background: rgb(179, 199, 209);
border-radius: 4px;
}
.up {
height: 50%;
width: 100%;
display: flex;
}
.up-left {
width: 64px;
display: flex;
justify-content: center;
align-items: center;
background: #ddd;
}
.up-right {
padding-top: 16px;
width: 100%;
border-bottom: 1px solid red;
}