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
| let horizontalConstraint = NSLayoutConstraint( | |
| item: newView, | |
| attribute: NSLayoutAttribute.centerX, | |
| relatedBy: NSLayoutRelation.equal, | |
| toItem: view, | |
| attribute: NSLayoutAttribute.centerX, | |
| multiplier: 1.0, | |
| constant: 0 | |
| ) |
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
| let horizontalConstraint = newView.centerXAnchor.constraint(equalTo: view.centerXAnchor) | |
| view.addConstraints([horizontalConstraint]) |
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
| newView.setContentCompressionResistancePriority(.defaultHigh, for: .vertical) | |
| newView.setContentHuggingPriority(.defaultLow, for: .horizontal) |
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
| //Old way of using var | |
| var myAge = 27; //this can change | |
| var myGender = "Male"; //this cannot change | |
| //To express the above in the new way | |
| let myAge = 27; //I use let because my age will always change | |
| const myGender = "Male"; |
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
| //Person.js module/class | |
| const Person = { | |
| name: 'Abel' | |
| }; | |
| export default Person |
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
| //utility module/class | |
| export const baseData = 10; | |
| export const baseUrl = 'agoiabeladeyemi.com'; |
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
| //We can import the Person class like below: | |
| import Person from './Person'; | |
| //We can even give it a different name like below | |
| import Pers from './Person'; | |
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
| //notice the {} | |
| import { baseData } from './Utility'; | |
| import { baseUrl } from './Utility'; | |
| //we can even use alias like below | |
| import { baseData as SomethingElse } from './Utility'; |
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
| class Person { | |
| //The constructor will be called first | |
| constructor () { | |
| this.name = 'Abel'; | |
| } | |
| printMyName() { | |
| console.dir(this.name); | |
| } |
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
| class Human { | |
| constructor () { | |
| this.gender = 'Male'; | |
| } | |
| printGender() { | |
| console.dir(this.gender); | |
| } | |
| } | |
| //The extends keyword means |