Programming Lang Idiosyncrasies and Similarities
Posted on September 2, 2022
Tags: codeetc
0.0.1 Destructuring
Changing property “size” to 3:
- haskell record type
someRecordType{ size = 3}
- js
{...props,"size":3}
0.0.2 Case sensititivity
- Haskell functions must be lowercase
- React components must be Uppercase
0.0.3 File naming
- Golang test files must end in “test”
- “helloworld_test.go”
- Golang test functions must begin with “Test”
func TestHello( *testing.T){...}
0.0.4 React
- React <li key=.. > must have a “key” property
0.0.5 JS fetch
Try fetch request with no-cors If returns opaque response, it means cors is not allowed by the website
const res = fetch(https://bleh.com/examples/data/asset/data/tempdata.json
,{mode: “no-cors”}).then((data)=>{console.log(data.body)})
If data.body is a readable stream, you first have to convert it to Know that .json() returns a promise so you have to pass it again
const res = fetch(https://bleh.com/examples/data/asset/data/tempdata.json
,{mode: “no-cors”}).then((re)=>{return re.json()}).then(response => {console.log(response)})
1 Python arrays and references
= [5]
a = a
b = [3]
b print(a) #[3]
= [5]
a = a
b = b + [3]
b print(a) #[3]
= [5]
a = a
b = b.append(3)
b print(a) #[5,3]
Why is the last case different?